Skip to content

Configurable tab title font size#90

Merged
austinywang merged 2 commits intomainfrom
configurable-tab-title-font-size
Apr 7, 2026
Merged

Configurable tab title font size#90
austinywang merged 2 commits intomainfrom
configurable-tab-title-font-size

Conversation

@austinywang
Copy link
Copy Markdown

@austinywang austinywang commented Apr 7, 2026

Adds a public appearance-level tabTitleFontSize setting to Bonsplit so host apps can control horizontal tab label sizing without patching internal metrics.

Changes:

  • Add BonsplitConfiguration.Appearance.tabTitleFontSize with a default of 11.
  • Use appearance.tabTitleFontSize for tab labels in TabItemView.
  • Derive zoom-indicator and shortcut-hint sizing from the configured title size.
  • Use the same appearance value for TabDragPreview so drag visuals stay consistent with the tab strip.

This keeps the change host-configurable while preserving the existing default look.


Summary by cubic

Make tab title font size configurable via a new appearance setting so host apps can control label sizing. Applies to the tab bar, drag preview, and scales accessory icons and hit areas to keep them readable.

  • New Features
    • Added BonsplitConfiguration.Appearance.tabTitleFontSize (default: 11).
    • Tab labels in TabItemView and TabDragPreview use this value.
    • Zoom/shortcut hint fonts and accessory slots (close/pin/zoom/hint) scale with tabTitleFontSize.

Written for commit d1576ed. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added configurable tabTitleFontSize to appearance settings, enabling customization of tab bar title font sizes (default: 11).
  • Improvements
    • Tab titles and accessory elements (zoom/close/pin/shortcut hints) now size consistently from appearance settings, improving visual consistency and layout behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2087024-f95d-46a0-8b04-e5cd7f7e33e8

📥 Commits

Reviewing files that changed from the base of the PR and between 0aa5957 and d1576ed.

📒 Files selected for processing (1)
  • Sources/Bonsplit/Internal/Views/TabItemView.swift

📝 Walkthrough

Walkthrough

Added a new public Appearance.tabTitleFontSize and updated internal tab views to derive title and accessory font/slot sizes from this appearance property instead of fixed TabBarMetrics constants.

Changes

Cohort / File(s) Summary
Configuration Addition
Sources/Bonsplit/Public/BonsplitConfiguration.swift
Added public var tabTitleFontSize: CGFloat; extended Appearance initializer to accept tabTitleFontSize (default 11); updated compact and spacious presets to include it.
Tab Drag Preview
Sources/Bonsplit/Internal/Views/TabDragPreview.swift
Replaced use of TabBarMetrics.titleFontSize with appearance.tabTitleFontSize for tab title font.
Tab Item View (layout & sizing)
Sources/Bonsplit/Internal/Views/TabItemView.swift
Switched title font to appearance.tabTitleFontSize; introduced computed accessoryFontSize and accessorySlotSize; replaced multiple uses of TabBarMetrics.titleFontSize / TabBarMetrics.closeButtonSize with these computed sizes for zoom button, shortcut hint, pin/close icon frames, and related layout measurements. No control-flow changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble at fonts, a tiny tweak so neat,
Titles now hop to the tune of config's beat.
Slots and icons stretch to fit the pace,
A sprightly appearance, snug in place. 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Configurable tab title font size' directly and concisely captures the main change: adding a configurable appearance-level property for tab title font sizing across multiple view components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch configurable-tab-title-font-size

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Apr 7, 2026

This review could not be run because your cubic account has exceeded the monthly review limit. If you need help restoring access, please contact contact@cubic.dev.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR exposes tabTitleFontSize as a public Appearance property (default 11 pt, matching the former TabBarMetrics.titleFontSize constant) and threads it through TabItemView and TabDragPreview, replacing four previous static-constant references. The default behaviour is fully preserved; the compact, spacious, and default presets all use 11 pt, and no existing callsites require changes.

Confidence Score: 5/5

Safe to merge; backward-compatible addition with no logic errors and a matching default.

All findings are P2 style suggestions. The new property correctly defaults to 11 pt (identical to the static constant it replaces), is threaded through every relevant view, and all existing presets explicitly or implicitly use the same value. No behavioural change for current callers.

No files require special attention

Important Files Changed

Filename Overview
Sources/Bonsplit/Public/BonsplitConfiguration.swift Adds tabTitleFontSize (default 11) to Appearance with correct initialiser wiring, property ordering, and preset declarations
Sources/Bonsplit/Internal/Views/TabItemView.swift Replaces all TabBarMetrics.titleFontSize references with appearance.tabTitleFontSize; secondary derived sizes retain existing max(8,...) floor
Sources/Bonsplit/Internal/Views/TabDragPreview.swift Drag-preview title font updated to appearance.tabTitleFontSize, keeping visual consistency with the live tab strip

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[BonsplitConfiguration.Appearance\ntabTitleFontSize: CGFloat = 11] -->|passed as appearance| B[TabItemView]
    A -->|passed as appearance| C[TabDragPreview]
    B -->|size: tabTitleFontSize| D[Tab Title Text]
    B -->|size: max8 tabTitleFontSize-2| E[Zoom Indicator Icon]
    B -->|size: max8 tabTitleFontSize-2| F[Shortcut Hint Text]
    B -->|size: max8 tabTitleFontSize-2| G[shortcutHintWidth NSFont]
    C -->|size: tabTitleFontSize| H[Drag Preview Title Text]
Loading

Reviews (1): Last reviewed commit: "feat: configurable tab title font size" | Re-trigger Greptile


Text(tab.title)
.font(.system(size: TabBarMetrics.titleFontSize))
.font(.system(size: appearance.tabTitleFontSize))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing lower-bound guard on primary title font

The zoom indicator and shortcut hint already protect against a sub-8 pt size via max(8, appearance.tabTitleFontSize - 2), but the main tab title text uses appearance.tabTitleFontSize directly. A caller who passes 0 or a very small value will silently render invisible tab titles while the secondary elements are clamped. Applying the same floor keeps behaviour consistent across all three callers.

Suggested change
.font(.system(size: appearance.tabTitleFontSize))
.font(.system(size: max(8, appearance.tabTitleFontSize)))

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Sources/Bonsplit/Internal/Views/TabItemView.swift (1)

136-137: Extract a shared derived font-size helper for accessory text/icons.

max(8, appearance.tabTitleFontSize - 2) is repeated in three places; centralizing it avoids drift and keeps sizing logic easier to maintain.

♻️ Suggested refactor
 struct TabItemView: View {
@@
+    private var accessoryFontSize: CGFloat {
+        max(8, appearance.tabTitleFontSize - 2)
+    }
@@
                 Image(systemName: "arrow.up.left.and.arrow.down.right")
-                    .font(.system(size: max(8, appearance.tabTitleFontSize - 2), weight: .semibold))
+                    .font(.system(size: accessoryFontSize, weight: .semibold))
@@
-        let font = NSFont.systemFont(ofSize: max(8, appearance.tabTitleFontSize - 2), weight: .semibold)
+        let font = NSFont.systemFont(ofSize: accessoryFontSize, weight: .semibold)
@@
                 Text(shortcutHintLabel)
-                    .font(.system(size: max(8, appearance.tabTitleFontSize - 2), weight: .semibold, design: .rounded))
+                    .font(.system(size: accessoryFontSize, weight: .semibold, design: .rounded))

Also applies to: 227-229, 237-238

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/Bonsplit/Internal/Views/TabItemView.swift` around lines 136 - 137,
Create a single helper to compute the accessory font size (e.g., a private
computed property or method named accessoryFontSize or derivedAccessoryFontSize
in the TabItemView struct) that returns max(8, appearance.tabTitleFontSize - 2),
then replace the three inline occurrences of max(8, appearance.tabTitleFontSize
- 2) (used in the TabItemView body for accessory text/icons and the font
modifiers at the spots around the current .font(.system(size: ...)) calls) with
a call to that helper; keep the helper private to TabItemView (or as an
Appearance extension if used elsewhere) and use it in all places referenced in
this file so the sizing logic is centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Sources/Bonsplit/Internal/Views/TabItemView.swift`:
- Around line 136-137: Create a single helper to compute the accessory font size
(e.g., a private computed property or method named accessoryFontSize or
derivedAccessoryFontSize in the TabItemView struct) that returns max(8,
appearance.tabTitleFontSize - 2), then replace the three inline occurrences of
max(8, appearance.tabTitleFontSize - 2) (used in the TabItemView body for
accessory text/icons and the font modifiers at the spots around the current
.font(.system(size: ...)) calls) with a call to that helper; keep the helper
private to TabItemView (or as an Appearance extension if used elsewhere) and use
it in all places referenced in this file so the sizing logic is centralized.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a0bf21e-fac7-4e70-a4a5-fb66e0b7e3f0

📥 Commits

Reviewing files that changed from the base of the PR and between b2788b1 and 0aa5957.

📒 Files selected for processing (3)
  • Sources/Bonsplit/Internal/Views/TabDragPreview.swift
  • Sources/Bonsplit/Internal/Views/TabItemView.swift
  • Sources/Bonsplit/Public/BonsplitConfiguration.swift

@austinywang austinywang merged commit 098d9fa into main Apr 7, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant